<?php
	class News_Model extends CI_Model
	{
		var $table_news = "db_news";
		var $table_news_product = "db_news_product";
		function __construct()
		{
			parent::__construct();
			
		}
		public function show()
		{
			return $this->db->get($this->table_news)->result();
		}
		public function show_list_product($id)
		{
			$this->db->where('id_news',$id);
			return $this->db->get($this->table_news_product)->result();
		}
		public function get_news_product($id)
		{
			$this->db->where('id_news_product',$id);
			return $this->db->get($this->table_news_product)->row();
		}
		public function get_name_cat($id)
		{
			$q = $this->db->get_where($this->table_news,array('id_cat'=>$id));
			if($q->num_rows() > 0)
			{
				return $q->row()->name_cat;
			}
			else
			{
				return false;
			}
		}
		public function get_url_cat($url)
		{
			$q = $this->db->get_where($this->table_news,array('id_cat'=>$url));
			if($q->num_rows() > 0)
			{
				return $q->row();
			}
			else
			{
				return false;
			}
		}
        public function get_url_cat2($url)
		{
			$q = $this->db->get_where($this->table_news,array('url'=>$url));
			if($q->num_rows() > 0)
			{
				return $q->row()->id_cat;
			}
			else
			{
				return false;
			}
		}
		
	}
?>